<%--
  Created by IntelliJ IDEA.
  User: zhong
  Date: 2020/5/4
  Time: 15:34
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/manage/inc/header" />
<jsp:include page="/manage/inc/menu" />
<div class="main-wrap">
    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">管理员角色管理</span></div>
    </div>
    <form action="#" method="post">
        <table class="search-tab">
            <tr>
                <th width="120">选择角色:</th>
                <td>
                    <select name="roleId" id="roleId">
                        <option value="">全部</option>
                        <c:forEach items="${requestScope.roles}" var="role">
                            <option value="${role.id}">${role.name}</option>
                        </c:forEach>
                    </select>
                </td>
                <td><input type="hidden" value="${requestScope.admin.id}" name="adminId"></td>
                <td><input class="btn btn-primary btn2" name="sub" id="add" value="添加" type="button"></td>
            </tr>
        </table>
    </form>
    <div class="result-wrap">
        <div class="result-title">
            <div class="result-list">
            </div>
        </div>
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                    <th>序号</th>
                    <th>管理员账号</th>
                    <th>管理员角色</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.admin.roles}" varStatus="stat" var="role">
                    <tr>
                        <td class="tc"><input  type="checkbox"></td>
                        <td>${stat.count}</td>
                        <td>${requestScope.admin.name}</td>
                        <td>${role.name}</td>
                        <td><a href="#" onclick="del(${role.id})">删除</a></td>
                    </tr>
                </c:forEach>

            </table>
        </div>
    </div>
</div>
<!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>
<script>
    function del(roleId) {
        var data = {adminId:${requestScope.admin.id},roleId:roleId};
        $.get("${pageContext.request.contextPath}/manage/admin/adminRolesDelete",data,function (data) {
        });
        location.reload();
    }
</script>
<script>
    $(function () {
        $("#add").click(function () {
            var roleId = $("#roleId").val();
            var adminId = ${requestScope.admin.id};
            var data = {adminId:adminId,roleId:roleId};
            $.get("${pageContext.request.contextPath}/manage/admin/adminRolesInsert",data,function (data) {
            });
            location.reload();
        });
    });
</script>
